package cn.gdcp.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.widget.Toast;

import static android.content.Context.CONNECTIVITY_SERVICE;

public class Receiver extends BroadcastReceiver {
    IOnTimeChangeListener listener;

    public Receiver(MainActivity listener) {
        this.listener = listener;
    }

    @Override

    public void onReceive(Context context, Intent intent) {
        listener.changTime();
        ConnectivityManager connectionManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectionManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if(networkInfo.isConnected()){
            Toast.makeText(context, "测试：WIFI网络连接成功",Toast.LENGTH_LONG).show(); }
        else{
            Toast.makeText(context, "测试：WIFI网络连接失败",Toast.LENGTH_LONG).show();
        }
    }
}
